package com.kvest.ula.activities;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.kvest.ula.R;
import com.kvest.ula.android.UlaclubListAdapter;
import com.kvest.ula.core.Settings;

public class ULAClubActivity extends ULABaseActivity
{
	@Override
    public void onCreate(Bundle savedInstanceState) 
    {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ulaclub);
        
        if (Settings.getSettings().getInterfaceColor() == Settings.IC_BLACK)
        {
        	findViewById(R.id.ulaclub_main_layout).setBackgroundDrawable(getResources().getDrawable(R.drawable.black_bg));
        }
        
        setContent();
        
        setComponents();
    }
	
	private void setContent()
	{
		ListView contentList = (ListView)findViewById(R.id.ulaclub_view_list);
		if (contentList != null)
		{			
			UlaclubListAdapter adapter = new UlaclubListAdapter(getApplicationContext(),  R.layout.city_list_item, getResources().getStringArray(R.array.ulaclub_items));
			contentList.setAdapter(adapter);
			
			contentList.setOnItemClickListener(new AdapterView.OnItemClickListener() 
	        {
		        public void onItemClick(AdapterView<?> parent, View itemClicked, int position, long id) 
		        {
		        	showULAClubView(position);
		        }
	        });
		}
	}
	
	private void showULAClubView(int position)
	{
		Intent intent = new Intent(this, ULAClubItem.class);
		switch (position) 
		{
			case 0: intent.putExtra(ULAClubItem.PART_NUMBER, ULAClubItem.CONTACTS_PART); break;
			case 1: intent.putExtra(ULAClubItem.PART_NUMBER, ULAClubItem.FOR_PARTNERS_PART); break;
			case 2: intent.putExtra(ULAClubItem.PART_NUMBER, ULAClubItem.FOR_PARTICIPANT_PART); break;
			case 3: intent.putExtra(ULAClubItem.PART_NUMBER, ULAClubItem.BECOME_PARTICIPANT_PART); break;
			case 4: intent.putExtra(ULAClubItem.PART_NUMBER, ULAClubItem.TERMS_PART); break;
		}
		
		startActivity(intent);
	}
	
	private void setComponents()
	{
		int textSize = Settings.getSettings().getFullFontSize();
		((TextView)findViewById(R.id.ulaclub_head_label)).setTextSize(textSize); 
	}
}
